package com.blackcat.mybatisplus.wrapper.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* mybatis plus 配置类
* @author zhanghui
* @since 2023/4/10 15:01
*/
@Configuration
@MapperScan("com.blackcat.mybatisplus.wrapper.mapper")
public class MyInterceptorConfig {
    
    /**
     * mybatis 分页配置，必须配置否则查出来的数据不正确
     * @author : zhanghui
     * @since : 2023/4/10 15:04
    */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE));
//        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

}
